<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
</style>


<script src="http://test.i-h5.cn/wzc_game/ydzx/js/jquery-2.1.0.js"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script>
	function getCookie(name)
	{
		var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
		if(arr=document.cookie.match(reg)){
			alert (unescape(arr[2]));
		}else{
			alert ("空");
		}
	}	
	
	getCookie("aaa");

	var wxconfig = {};
	wxconfig.appId = "";
	wxconfig.timestamp = "";
	wxconfig.nonceStr = "";
	wxconfig.signature = "";

	//游戏链接地址目录
	var gameUrl = window.location.href;
	

	$.ajax({
		url : "http://java.i-h5.cn/LaLaLand/Share.do",
		data : {
			homeurl : gameUrl
		},
		dataType : "json",
		type : "get",
		success : function(data) {
			console.log(data.appid);
			wxconfig.appId = data.appid;
			wxconfig.timestamp = data.timestamp;
			wxconfig.nonceStr = data.noncestr;
			wxconfig.signature = data.signature;
			wx.config({
				debug : false,
				appId : wxconfig.appId,
				timestamp : wxconfig.timestamp,
				nonceStr : wxconfig.nonceStr,
				signature : wxconfig.signature,
				jsApiList : [ 'checkJsApi', 'onMenuShareTimeline',
						'onMenuShareAppMessage', 'onMenuShareQQ',
						'onMenuShareWeibo', 'onMenuShareQZone',
						'hideMenuItems', 'showMenuItems',
						'hideAllNonBaseMenuItem', 'showAllNonBaseMenuItem',
						'translateVoice', 'startRecord', 'stopRecord',
						'onVoiceRecordEnd', 'playVoice', 'onVoicePlayEnd',
						'pauseVoice', 'stopVoice', 'uploadVoice',
						'downloadVoice', 'chooseImage', 'previewImage',
						'uploadImage', 'downloadImage', 'getNetworkType',
						'openLocation', 'getLocation', 'hideOptionMenu',
						'showOptionMenu', 'closeWindow', 'scanQRCode',
						'chooseWXPay', 'openProductSpecificView', 'addCard',
						'chooseCard', 'openCard' ]
			});
		}
	});

	function is_weixin() {
		var ua = navigator.userAgent.toLowerCase();
		if (ua.match(/MicroMessenger/i) == "micromessenger") {
			return true;
		} else {
			return false;
		}
	}

	//分享到朋友数据
	var sharedata = {
		title : '分享语',
		desc : '分享语',
		link : 'http://java.i-h5.cn/LaLaLand/index.html',
		imgUrl : '',
		success: function () { 
            alert('分享成功');
        },
        cancel: function () { 
            alert('分享失败');
        }
	};
	console.log(sharedata);
	//分享到朋友圈数据 默认和分享朋友一样
	var timelinedata = {
		title : sharedata.title,
		link : 'http://java.i-h5.cn/LaLaLand/index.html',
		imgUrl : sharedata.imgUrl
	}
	

    sharedata.trigger = function (res) {};
    sharedata.cancel = function (res) {};
    sharedata.fail = function (res) {};
    sharedata.success = function (res) {};

    timelinedata.trigger = function (res) {};
    timelinedata.cancel = function (res) {};
    timelinedata.fail = function (res) {};
    timelinedata.success = function (res) {};

    wx.ready(function () {
        //type: 'link',//分享类型，music、video、link，默认是link
        //dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
        wx.onMenuShareAppMessage(sharedata);

        // 2.2 监听“分享到朋友圈”按钮点击、自定义分享内容及分享结果接口
        wx.onMenuShareTimeline(timelinedata);

        console.log("初始化wx分享成功！");
    });
</script>

</head>

<body>

</body>


</html>